public class RectanglePlus implements Relatable {
    public int width = 0;
    public int height = 0;
    public Point origin;

    // four constructors
    public RectanglePlus() {
	origin = new Point(0, 0);
    }
    public RectanglePlus(Point p) {
	origin = p;
    }
    public RectanglePlus(int w, int h) {
	origin = new Point(0, 0);
	width = w;
	height = h;
    }
    public RectanglePlus(Point p, int w, int h) {
	origin = p;
	width = w;
	height = h;
    }

    // a method for moving the rectangle
    public void move(int x, int y) {
	origin.x = x;
	origin.y = y;
    }

    // a method for computing the area of the rectangle
    public int getArea() {
	return width * height;
    }
    
    // a method required to implement the Relatable interface
    public int isLargerThan(Relatable other) {
    	RectanglePlus otherRect = (RectanglePlus)other;
    	if (this.getArea() < otherRect.getArea())
    		return -1;
    	else if (this.getArea() > otherRect.getArea())
    		return 1;
    	else
    		return 0;    		
    }

	public RectanglePlus findLargest(Relatable object1, Relatable object2){
		RectanglePlus other1 = (RectanglePlus)object1;
		RectanglePlus other2 = (RectanglePlus)object2;
		if(other1.getArea()>other2.getArea()){

			if(this.getArea()>other1.getArea())
				return this;
			else 
				return other1;
		}
		else {
			if(this.getArea()>other2.getArea())
				return this;
			else 
				return other2;
		}
	}


	public static void main(String[] args) {
		RectanglePlus hhhh=new RectanglePlus(20,10);
		RectanglePlus rrrr=new RectanglePlus(15,10);
		RectanglePlus pppp=new RectanglePlus(5,10);
	
		System.out.println(hhhh.isLargerThan(rrrr));
		System.out.println((hhhh.findLargest(rrrr,pppp)).getArea());
	}


}
